//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Common Core Extensions
//===============================================================================

using System;
using System.Reflection;

namespace EntLibContrib.Common
{
	/// <summary>
	/// This interface defines the contract that a class must implement to write
	/// both non-null and nullable data. Use this interface polymorphically rather
	/// than the direct implementations, that way it does not matter how data is written
	/// you can use a single nullable writer method to deal with null values.
	/// </summary>
	public interface INullableWriter<T>
	{
		#region Properties
		/// <summary>
		/// The number of columns in the underlying row;
		/// </summary>
		int FieldCount
		{
			get;
		}

		/// <summary>
		/// Gets the underlying row.
		/// </summary>
		/// <value>The row.</value>
		T Row
		{
			get;
		}
		#endregion

		#region Methods
		/// <summary>
		/// Gets the column name at the ordinal position.
		/// </summary>
		/// <param name="ordinal">The column ordinal.</param>
		/// <returns></returns>
		string GetName(int ordinal);
		/// <summary>
		/// Gets the ordinal position of the column name.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		int GetOrdinal(string name);
		/// <summary>
		/// Sets the boolean value.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The boolean value to insert into the column.</param>
		void SetBoolean(string name, bool value);
		/// <summary>
		/// Sets the nullable boolean.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The nullable boolean value to insert into the column.</param>
		void SetNullableBoolean(string name, bool value);
		/// <summary>
		/// Sets the byte.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The byte value to insert into the column.</param>
		void SetByte(string name, byte value);
		/// <summary>
		/// Sets the nullable byte.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The nullable byte value to insert into the column.</param>
		void SetNullableByte(string name, byte value);
		/// <summary>
		/// Sets the char.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The char value to insert into the column.</param>
		void SetChar(string name, char value);
		/// <summary>
		/// Sets the nullable char.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The nullable char value to insert into the column.</param>
		void SetNullableChar(string name, char value);
		/// <summary>
		/// Sets the date time.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The datetime value to insert into the column.</param>
		void SetDateTime(string name, DateTime value);
		/// <summary>
		/// Sets the nullable date time.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The nullable datetime value to insert into the column.</param>
		void SetNullableDateTime(string name, DateTime value);
		/// <summary>
		/// Sets the decimal.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The decimal value to insert into the column.</param>
		void SetDecimal(string name, decimal value);
		/// <summary>
		/// Sets the nullable decimal.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The nullable decimal value to insert into the column.</param>
		void SetNullableDecimal(string name, decimal value);
		/// <summary>
		/// Sets the double.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The double value to insert into the column.</param>
		void SetDouble(string name, double value);
		/// <summary>
		/// Sets the nullable double.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The nullable double value to insert into the column.</param>
		void SetNullableDouble(string name, double value);
		/// <summary>
		/// Sets the float.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The float value to insert into the column.</param>
		void SetFloat(string name, float value);
		/// <summary>
		/// Sets the nullable float.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The nullable float value to insert into the column.</param>
		void SetNullableFloat(string name, float value);
		/// <summary>
		/// Sets the Guid.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The guid value to insert into the column.</param>
		void SetGuid(string name, Guid value);
		/// <summary>
		/// Sets the nullable Guid.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The nullable guid value to insert into the column.</param>
		void SetNullableGuid(string name, Guid value);
		/// <summary>
		/// Sets the short integer.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The short value to insert into the column.</param>
		void SetInt16(string name, short value);
		/// <summary>
		/// Sets the nullable short integer.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The nullable short value to insert into the column.</param>
		void SetNullableInt16(string name, short value);
		/// <summary>
		/// Sets the integer.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The int value to insert into the column.</param>
		void SetInt32(string name, int value);
		/// <summary>
		/// Sets the nullable integer.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The nullable int value to insert into the column.</param>
		void SetNullableInt32(string name, int value);
		/// <summary>
		/// Sets the long integer.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The long value to insert into the column.</param>
		void SetInt64(string name, long value);
		/// <summary>
		/// Sets the nullable long integer.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The nullable long value to insert into the column.</param>
		void SetNullableInt64(string name, long value);
		/// <summary>
		/// Sets the string.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The string value to insert into the column.</param>
		void SetString(string name, string value);
		/// <summary>
		/// Sets the nullable string.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The nullable string value to insert into the column.</param>
		void SetNullableString(string name, string value);
		/// <summary>
		/// Sets the time span.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The timespan value to insert into the column.</param>
		void SetTimeSpan(string name, TimeSpan value);
		/// <summary>
		/// Sets the nullable time span.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The nullable timespan value to insert into the column.</param>
		void SetNullableTimeSpan(string name, TimeSpan value);
		/// <summary>
		/// Sets a data value with conversion to the given type.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The object value to insert into the column.</param>
		/// <param name="type">The data type of the value to be inserted.</param>
		void SetValue(string name, object value, Type type);
		/// <summary>
		/// Sets a data value with conversion to the given type.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="value">The nullable object value to insert into the column.</param>
		/// <param name="type">The data type of the value to be inserted.</param>
		void SetNullableValue(string name, object value, Type type);
		/// <summary>
		/// Sets the type information for the column.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="type">The type.</param>
		void SetFieldType(string name, Type type);
		/// <summary>
		/// Determines whether the specified name is valid field.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns>
		/// 	<c>true</c> if the specified name is a field; otherwise, <c>false</c>.
		/// </returns>
		bool IsField(string name);
		/// <summary>
		/// Determines whether the named column can take a null value.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns>
		/// 	<c>true</c> if nullable; otherwise <c>false</c>.
		/// </returns>
		bool IsNullable(string name);
		#endregion
	}
}
